package com.ymatou.query.trading.api.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.query.trading.api.parameter.GetSellerOrdersListBean;
import com.ymatou.query.trading.api.service.GetSellerOrdersListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.utils.constant.ECode;

/**
 * 获取商家订单列表 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetSellerOrdersList {

	private static GetSellerOrdersListBean getsellerorderslistbean;
	private static GetSellerOrdersListCall getsellerorderslistcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商家订单列表");
	}

	@Before
	public void caseUp() {

		getsellerorderslistbean = new GetSellerOrdersListBean();
		getsellerorderslistcall = new GetSellerOrdersListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getsellerorderslistcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetSellerOrdersList_001() {
		Logger.start(true,"获取商家订单列表成功");
		try {
			// 创建订单
			PlaceOrderResp placeOrderResp=new OrderCallService().createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId =placeOrderResp.getOrderList().get(0).getSellerId();
			int userId =placeOrderResp.getUserId();         
			int tradingId = placeOrderResp.getTradingId();	
			int activityId = 0;
			// 参数
			getsellerorderslistbean.setActivityId(activityId);
			getsellerorderslistbean.setOrderNum(10);
			getsellerorderslistbean.setSellerId(sellerId);
			// 发送请求
			getsellerorderslistcall.setData(getsellerorderslistbean);
			getsellerorderslistcall.callService();
			Logger.comment("getsellerorderslistcall send:" + getsellerorderslistcall.getEntityString());
			Logger.comment("getsellerorderslistcall response:" + getsellerorderslistcall.getReturnData());
			Logger.verifyEquals(ECode.SUCCESS, getsellerorderslistcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerorderslistcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_GetSellerOrdersList_002() {
		Logger.start(true,"卖家用户id为空");
		try {
			// 创建订单
			PlaceOrderResp placeOrderResp=new OrderCallService().createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId =placeOrderResp.getOrderList().get(0).getSellerId();
			int userId =placeOrderResp.getUserId();         
			int tradingId = placeOrderResp.getTradingId();	
			int activityId = 0;
			// 参数
			getsellerorderslistbean.setActivityId(activityId);
			getsellerorderslistbean.setOrderNum(10);
			// getsellerorderslistbean.setSellerId(SellerId);
			// 发送请求
			getsellerorderslistcall.setData(getsellerorderslistbean);
			getsellerorderslistcall.callService();
			Logger.comment("getsellerorderslistcall send:" + getsellerorderslistcall.getEntityString());
			Logger.comment("getsellerorderslistcall response:" + getsellerorderslistcall.getReturnData());
			Logger.verifyEquals(ECode.ERROR400, getsellerorderslistcall.getCode(), "验证Code");
			// Logger.verifyEquals(ErrorCode.SUCCESSMSG,
			// getsellerorderslistcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}